package se.webbzon.boltzmann.game.event;

import java.util.Collection;

import se.webbzon.boltzmann.object.cinema.AbstractCinemaTerminator;
import se.webbzon.oschi01.worldarea.WorldArea;

public class CinemaEndEvent extends AbstractGameEvent {

	/*============================================================
	Public Methods
	============================================================*/
	
	@Override protected void onBegin(WorldArea world) {
		Collection<AbstractCinemaTerminator> terminators = world.findInstances(AbstractCinemaTerminator.class);
		if (!terminators.isEmpty()) {
			AbstractCinemaTerminator terminator = terminators.iterator().next();
			WorldArea reality = terminator.getReality();
			world.gotoWorldArea(reality);
			world.destroyAll();
			terminator.terminate();
		}
		end();
	}

	@Override protected void onEnd() {};

}
